import axios from 'axios'
export default {
  getUserInfo (context) {
      //用请求的userInfo改变状态userInfo的值
    axios({
      methods: 'get',
      url: 'api/user/queryUserInfo'
    })
      .then(res => {
        const userInfo = res.data.data
        context.commit('setUserInfo', userInfo)
      })
      .catch(err => {
        console.log(err)
      })
  },
  getMasterOrders (context) {
    axios
      .get('/api/manager/findManagerPendingOrders')
      .then(res => {
        // console.log(res.data.data)
        context.commit('setMasterOrders', res.data.data)
      })
      .catch(err => {
        console.log(err)
      })
  },
  getWorksOrders (context) {
    axios('/api/worker/outworkerPending')
      .then(res => {
        // console.log(res.data.data)
        context.commit('setWorkerOrders', res.data.data)
      })
      .catch(err => {
        console.log(err)
      })
  },
  getOrderDetail (context, status) {
    axios({
      url: '/api/workOrder/managerQueryWorkOrder',
      params: {
        lsStatus: status
      }
    })
      .then(res => {
        // console.log(res.data.data)
        context.commit('setOrderDetail', res.data.data)
      })
      .catch(err => {
        console.log(err)
      })
  }
}
